package service;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import dao.BlackListDao;
import dao.ClickTrendDao;
import dao.impl.BlackListDaoImpl;
import dao.impl.ClickTrendDaoImpl;
import domain.BlackList;
import domain.ClickTrend;

import java.util.List;

public class ClickTrendService {
    String valueAsString = null;
    private ClickTrendDao contacts = new ClickTrendDaoImpl();
    public String ToJson(ClickTrend clickTrend) {
        String hour = clickTrend.getHour();
        List<ClickTrend> list = contacts.SelectAdidCountByHour(hour);
        ObjectMapper objectMapper = new ObjectMapper();
        try {
            valueAsString = objectMapper.writeValueAsString(list);
        } catch (JsonProcessingException e) {
            e.printStackTrace();
        }
        return valueAsString;
    }
}
